Searching
for Help with Keywords
An
application can enable the user to search for topics based on full or partial
keywords. The following example searches for the keyword Keyboard and
displays the corresponding topic, if found:
WinHelp(hwnd, "myhelp.hlp", HELP_KEY,
"Keyboard");
If the topic
is not found, Windows Help displays the Index tab. If more than one topic has
the same keyword, Windows Help displays the list of topics in the Topics Found
dialog.
An
application can give the user more options in a search by specifying partial
keywords. When a partial keyword is given, Windows Help usually displays the Index
tab to allow the user to continue the search or return to the application.
However, if there is an exact match and no other topic exists with the given
keyword, Windows Help displays the topic. The following example opens the Find
tab and selects the first keyword in the list starting with the letters Ke:
WinHelp(hwnd, "myhelp.hlp",
HELP_PARTIALKEY, "Ke");
When the
HELP_KEY and HELP_PARTIALKEY values are specified in the WinHelp
HGLOBAL hglblmkh;
MULTIKEYHELP FAR* mkh;
PSTR pszKeyword = "Frame";
UINT cb;
cb = sizeof(MULTIKEYHELP) + lstrlen(pszKeyword);
hglblmkh = GlobalAlloc(GHND, (DWORD) cb);
if (hglblmkh == NULL)
break;
mkh = (MULTIKEYHELP FAR*) GlobalLock(hglblmkh);
mkh->mkSize = cb;
mkh->mkKeylist = 'L';
lstrcpy(mkh->szKeyphrase, pszKeyword);
WinHelp(hwnd, "myhelp.hlp", HELP_MULTIKEY, (DWORD) mkh);
GlobalUnlock(hglblmkh);
GlobalFree(hglblmkh);
If the
keyword is not found, Windows Help displays an error message. If more than one
topic has the keyword, Windows Help displays only the first topic.
Applications
cannot use alternative keyword tables unless the MULTIKEY option is specified
in the [OPTIONS] section of the project file.